{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 前三句是：1_载入单词本完成的任务.ipynb，如果不理解请参考该文件"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['a',\n",
       " 'aa',\n",
       " 'aal',\n",
       " 'aalii',\n",
       " 'aam',\n",
       " 'aani',\n",
       " 'aardvark',\n",
       " 'aardwolf',\n",
       " 'aaron',\n",
       " 'aaronic']"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "word = open('words','r')\n",
    "wordclean = sorted(list(set([word.strip().lower() for word in open('words','r')])))\n",
    "wordclean[:10]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 单词的\"签名 signature\"\n",
    "1. 每一个单词的所有字母排序后形成的内容就叫做该单词的`签名 signature`\n",
    "2. 通过比较两个单词的标识，可以判断两个单词是否互为`变位词`\n",
    "\n",
    "注: 如果两个单词互为`变位词`就表示两个单词中包含有相同的字母，每个字母出现的次数一样，但是顺序可能不一样。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['e', 'i', 'l', 's', 'v']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted('lives')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted('lives') == sorted('elvis')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sorted('love') == sorted('hate')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 设计函数signature，可以以字符串的形式，返回任意单词的签名"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def signature(word):\n",
    "    return ''.join(sorted(word))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'eilsv'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "signature('lives')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 设计函数anagram, 用来获得任意单词，在上文`wordclean`中的所有`变位词`列表\n",
    "\n",
    "思路: 假设要判断的单词为`cbc`, 首先得到`cbc`的签名`bbc`，然后循环wordclean中的所有单词，只要和`cbc`的签名一样的就放在生成的列表里。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def anagram(word):\n",
    "    return [w for w in wordclean if signature(w) == signature(word)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['dictionary', 'indicatory']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anagram('dictionary')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.27 s ± 75.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit anagram('dictionary') #获得此方法的运行时间"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "以上的方法对于每一个单词，都要重新搜索一遍所有的单词，显然太慢了。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 一个更快的方法\n",
    "\n",
    "一个很常见的加速搜索的方法，就是建立索引。在这里我想要建立如下索引:\n",
    "```\n",
    "abc:[abc, acb, bca, bac, cab, cba]\n",
    "ef:[ef, fe]\n",
    "...\n",
    "```\n",
    "这个索引每一个`签名` 以及每一个`签名`对应的所有单词的列表。\n",
    "\n",
    "这样假设我有一个单词 cab，想要得到它的`变位词`只需要两步骤:\n",
    "1. 得到`cab`的签名`abc`\n",
    "2. 去索引中找到`abc`后面的列表返回即可"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "以上`索引`可以通过`字典`来实现，思路如下：\n",
    "0. 整个索引用`字典`实现, 这个字典的键为所有的`签名`，值为每一个签名对应的`所有单词列表`\n",
    "1. 循环`wordclean`中的每一个单词\n",
    "2. 对于循环到的任何一个单词，得到它的`签名`\n",
    "3. 以这个`签名`为键，找到键值对，把这个单词加入到`值`中"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'a'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-32-fd8bd4f5004a>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mword\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mwordclean\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m     \u001b[0mwords_bysig\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0msignature\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;31m# 这段代码会出错，因为append方法使用的前提是要有一个列表\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mKeyError\u001b[0m: 'a'"
     ]
    }
   ],
   "source": [
    "words_bysig = {}\n",
    "\n",
    "for word in wordclean:\n",
    "    words_bysig[signature(word)].append(word)\n",
    "\n",
    "# 这段代码会出错，因为append方法使用的前提是要有一个列表\n",
    "# 但是按照我们的思路，对于我们第一次碰到的签名，我们还没有构建包含这个签名的键值对"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 需要用`defaultdict` 来实现上面的功能"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import collections"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "words_bysig = collections.defaultdict(list)\n",
    "\n",
    "for word in wordclean:\n",
    "    words_bysig[signature(word)].append(word)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "defaultdict(list,\n",
       "            {'a': ['a'],\n",
       "             'aa': ['aa'],\n",
       "             'aal': ['aal', 'ala'],\n",
       "             'aaiil': ['aalii'],\n",
       "             'aam': ['aam', 'ama'],\n",
       "             'aain': ['aani'],\n",
       "             'aaadkrrv': ['aardvark'],\n",
       "             'aadflorw': ['aardwolf'],\n",
       "             'aanor': ['aaron'],\n",
       "             'aacinor': ['aaronic', 'nicarao', 'ocarina'],\n",
       "             'aaacilnor': ['aaronical'],\n",
       "             'aaeinort': ['aaronite', 'aeration'],\n",
       "             'aaciinort': ['aaronitic'],\n",
       "             'aaru': ['aaru', 'aura'],\n",
       "             'ab': ['ab', 'ba'],\n",
       "             'aab': ['aba', 'baa'],\n",
       "             'aabbdeh': ['ababdeh'],\n",
       "             'aaabbu': ['ababua'],\n",
       "             'aabc': ['abac', 'caba'],\n",
       "             'aaabc': ['abaca'],\n",
       "             'aaabcet': ['abacate'],\n",
       "             'aaabcy': ['abacay'],\n",
       "             'aaabceint': ['abacinate'],\n",
       "             'aaabciinnot': ['abacination'],\n",
       "             'aabccissu': ['abaciscus'],\n",
       "             'aabcist': ['abacist'],\n",
       "             'aabck': ['aback'],\n",
       "             'aaabcilnt': ['abactinal'],\n",
       "             'aaabcillnty': ['abactinally'],\n",
       "             'aabcinot': ['abaction'],\n",
       "             'aabcort': ['abactor', 'acrobat'],\n",
       "             'aabclsuu': ['abaculus'],\n",
       "             'aabcsu': ['abacus'],\n",
       "             'aabdeit': ['abadite'],\n",
       "             'aabff': ['abaff'],\n",
       "             'aabft': ['abaft', 'bafta'],\n",
       "             'aaabceins': ['abaisance'],\n",
       "             'aabeirs': ['abaiser'],\n",
       "             'aabdeiss': ['abaissed'],\n",
       "             'aaabeeilnt': ['abalienate'],\n",
       "             'aaabeiilnnot': ['abalienation'],\n",
       "             'aabelno': ['abalone', 'balonea'],\n",
       "             'aaabm': ['abama'],\n",
       "             'aabeempr': ['abampere'],\n",
       "             'aabdnno': ['abandon'],\n",
       "             'aaabbdelnno': ['abandonable'],\n",
       "             'aabddenno': ['abandoned'],\n",
       "             'aabddelnnoy': ['abandonedly'],\n",
       "             'aabdeenno': ['abandonee'],\n",
       "             'aabdennor': ['abandoner', 'reabandon'],\n",
       "             'aabdemnnnot': ['abandonment'],\n",
       "             'aabcin': ['abanic', 'bianca'],\n",
       "             'aabenst': ['abantes'],\n",
       "             'aabinopstt': ['abaptiston'],\n",
       "             'aaabbmor': ['abarambo'],\n",
       "             'aabirs': ['abaris', 'arabis'],\n",
       "             'aabhiorrsst': ['abarthrosis'],\n",
       "             'aaabcilrrtu': ['abarticular'],\n",
       "             'aaabciilnorttu': ['abarticulation'],\n",
       "             'aabs': ['abas', 'saba'],\n",
       "             'aabes': ['abase'],\n",
       "             'aabdes': ['abased'],\n",
       "             'aabdelsy': ['abasedly'],\n",
       "             'aabdeensss': ['abasedness'],\n",
       "             'aabeemnst': ['abasement'],\n",
       "             'aabers': ['abaser', 'abrase'],\n",
       "             'aabgis': ['abasgi'],\n",
       "             'aabhs': ['abash'],\n",
       "             'aabdehs': ['abashed'],\n",
       "             'aabdehlsy': ['abashedly'],\n",
       "             'aabdeehnsss': ['abashedness'],\n",
       "             'aabehlsss': ['abashless'],\n",
       "             'aabehllsssy': ['abashlessly'],\n",
       "             'aabehmnst': ['abashment'],\n",
       "             'aaabis': ['abasia'],\n",
       "             'aabcis': ['abasic'],\n",
       "             'aabks': ['abask'],\n",
       "             'aabinss': ['abassin'],\n",
       "             'aaabdeirstz': ['abastardize'],\n",
       "             'aaabbelt': ['abatable'],\n",
       "             'aabet': ['abate', 'ateba', 'batea', 'beata'],\n",
       "             'aabeemntt': ['abatement'],\n",
       "             'aabert': ['abater', 'artabe', 'eartab', 'trabea'],\n",
       "             'aabist': ['abatis'],\n",
       "             'aabdeist': ['abatised'],\n",
       "             'aabnot': ['abaton'],\n",
       "             'aabort': ['abator'],\n",
       "             'aabiortt': ['abattoir'],\n",
       "             'aaabtu': ['abatua'],\n",
       "             'aabertu': ['abature'],\n",
       "             'aabev': ['abave'],\n",
       "             'aaabilx': ['abaxial'],\n",
       "             'aabeilx': ['abaxile'],\n",
       "             'aabez': ['abaze'],\n",
       "             'abb': ['abb', 'bab'],\n",
       "             'aabb': ['abba', 'baba'],\n",
       "             'aabbcemos': ['abbacomes'],\n",
       "             'aabbcy': ['abbacy'],\n",
       "             'aabbddei': ['abbadide'],\n",
       "             'aabbs': ['abbas'],\n",
       "             'aabbis': ['abbasi'],\n",
       "             'aabbiss': ['abbassi'],\n",
       "             'aabbdeiss': ['abbasside'],\n",
       "             'aaabbilt': ['abbatial'],\n",
       "             'aaabbcilt': ['abbatical'],\n",
       "             'abbess': ['abbess'],\n",
       "             'abbey': ['abbey', 'bebay'],\n",
       "             'abbdeeesty': ['abbeystede'],\n",
       "             'abbei': ['abbie'],\n",
       "             'abbot': ['abbot'],\n",
       "             'abbcoty': ['abbotcy'],\n",
       "             'abbillnostuu': ['abbotnullius'],\n",
       "             'abbhiopst': ['abbotship'],\n",
       "             'aabbeeirtv': ['abbreviate'],\n",
       "             'aabbeeilrtvy': ['abbreviately'],\n",
       "             'aabbeiinortv': ['abbreviation'],\n",
       "             'aabbeiorrtv': ['abbreviator'],\n",
       "             'aabbeiorrtvy': ['abbreviatory'],\n",
       "             'aabbeeirrtuv': ['abbreviature'],\n",
       "             'abby': ['abby', 'baby'],\n",
       "             'abbclmoou': ['abcoulomb'],\n",
       "             'aabdl': ['abdal'],\n",
       "             'aabdt': ['abdat', 'batad'],\n",
       "             'aabdeinr': ['abderian'],\n",
       "             'abdeeirt': ['abderite'],\n",
       "             'abdest': ['abdest'],\n",
       "             'aabbcdeil': ['abdicable'],\n",
       "             'aabcdint': ['abdicant'],\n",
       "             'aabcdeit': ['abdicate'],\n",
       "             'aabcdiinot': ['abdication'],\n",
       "             'aabcdeiitv': ['abdicative'],\n",
       "             'aabcdiort': ['abdicator'],\n",
       "             'abdeil': ['abdiel', 'baldie'],\n",
       "             'abdeiitv': ['abditive'],\n",
       "             'abdiorty': ['abditory'],\n",
       "             'abdemno': ['abdomen'],\n",
       "             'aabdilmno': ['abdominal'],\n",
       "             'aabdeilmnos': ['abdominales'],\n",
       "             'aaabdiilmnno': ['abdominalian'],\n",
       "             'aabdillmnoy': ['abdominally'],\n",
       "             'aabdeiimnnooorrt': ['abdominoanterior'],\n",
       "             'aaabccddiimnoor': ['abdominocardiac'],\n",
       "             'abcdeeiimnnoosst': ['abdominocentesis'],\n",
       "             'abccdiimnoosty': ['abdominocystic'],\n",
       "             'aabdegiilmnnoot': ['abdominogenital'],\n",
       "             'abcdeehimmnooorsttyy': ['abdominohysterectomy'],\n",
       "             'abdehimmnoooorsttyy': ['abdominohysterotomy'],\n",
       "             'abdeiimnooooprrst': ['abdominoposterior'],\n",
       "             'abcdeimnooops': ['abdominoscope'],\n",
       "             'abcdimnooopsy': ['abdominoscopy'],\n",
       "             'aabccdhiimnooort': ['abdominothoracic'],\n",
       "             'abdimnoosu': ['abdominous'],\n",
       "             'aaabdgiilmnnoov': ['abdominovaginal', 'vaginoabdominal'],\n",
       "             'aabcdeiilmnoosv': ['abdominovesical', 'vesicoabdominal'],\n",
       "             'abcdeu': ['abduce'],\n",
       "             'abcdensu': ['abducens'],\n",
       "             'abcdentu': ['abducent'],\n",
       "             'abcdtu': ['abduct'],\n",
       "             'abcdinotu': ['abduction'],\n",
       "             'abcdortu': ['abductor'],\n",
       "             'abe': ['abe', 'bae', 'bea'],\n",
       "             'aabem': ['abeam'],\n",
       "             'aaber': ['abear'],\n",
       "             'aaabceenr': ['abearance'],\n",
       "             'aaabcdeeinr': ['abecedarian'],\n",
       "             'aabcdeeimru': ['abecedarium'],\n",
       "             'aabcdeery': ['abecedary'],\n",
       "             'abde': ['abed', 'bade', 'bead'],\n",
       "             'abeghi': ['abeigh'],\n",
       "             'abel': ['abel', 'able', 'albe', 'bale', 'beal', 'bela', 'blae'],\n",
       "             'abeel': ['abele', 'albee'],\n",
       "             'aabeil': ['abelia'],\n",
       "             'aabeiln': ['abelian', 'nebalia'],\n",
       "             'aabceeil': ['abelicea'],\n",
       "             'abeeilt': ['abelite'],\n",
       "             'abcehlmossu': ['abelmoschus'],\n",
       "             'abeklmos': ['abelmosk'],\n",
       "             'aabeilnno': ['abelonian'],\n",
       "             'abeeelrt': ['abeltree'],\n",
       "             'aabceeegnrrs': ['abencerrages'],\n",
       "             'abceeinrt': ['abenteric', 'bicrenate'],\n",
       "             'aabehiimpty': ['abepithymia'],\n",
       "             'abdeeenr': ['aberdeen'],\n",
       "             'abdeeeinrv': ['aberdevine'],\n",
       "             'aabdeinnor': ['aberdonian'],\n",
       "             'aabeir': ['aberia', 'baeria', 'baiera'],\n",
       "             'aabceenrr': ['aberrance'],\n",
       "             'aabcenrry': ['aberrancy'],\n",
       "             'aabenrrt': ['aberrant'],\n",
       "             'aabeerrt': ['aberrate'],\n",
       "             'aabeinorrt': ['aberration'],\n",
       "             'aaabeilnorrt': ['aberrational'],\n",
       "             'aabeorrrt': ['aberrator'],\n",
       "             'abeeemorrrt': ['aberrometer'],\n",
       "             'abceeooprrs': ['aberroscope'],\n",
       "             'aabcenorrtu': ['aberuncator'],\n",
       "             'abet': ['abet', 'bate', 'beat', 'beta'],\n",
       "             'abeemntt': ['abetment', 'batement'],\n",
       "             'aabeltt': ['abettal'],\n",
       "             'abeortt': ['abettor', 'taboret'],\n",
       "             'aaabceinotuv': ['abevacuation'],\n",
       "             'abey': ['abey'],\n",
       "             'aabceeny': ['abeyance'],\n",
       "             'aabcenyy': ['abeyancy'],\n",
       "             'aabenty': ['abeyant'],\n",
       "             'aaabdfr': ['abfarad'],\n",
       "             'abehnry': ['abhenry'],\n",
       "             'aabehiks': ['abhiseka'],\n",
       "             'aabbehilmno': ['abhominable'],\n",
       "             'abhor': ['abhor'],\n",
       "             'abceehnorr': ['abhorrence'],\n",
       "             'abcehnorry': ['abhorrency'],\n",
       "             'abehnorrt': ['abhorrent', 'earthborn'],\n",
       "             'abehlnorrty': ['abhorrently'],\n",
       "             'abehorrr': ['abhorrer', 'harborer'],\n",
       "             'abbehilorr': ['abhorrible'],\n",
       "             'abghinorr': ['abhorring'],\n",
       "             'abhnoors': ['abhorson'],\n",
       "             'aabdil': ['abidal'],\n",
       "             'aabcdein': ['abidance'],\n",
       "             'abdei': ['abide'],\n",
       "             'abdeir': ['abider', 'bardie'],\n",
       "             'abdii': ['abidi'],\n",
       "             'abdgiin': ['abiding'],\n",
       "             'abdgiilny': ['abidingly'],\n",
       "             'abdegiinnss': ['abidingness'],\n",
       "             'abei': ['abie'],\n",
       "             'abeis': ['abies', 'beisa'],\n",
       "             'aabeeitt': ['abietate'],\n",
       "             'abeeeint': ['abietene'],\n",
       "             'abceiit': ['abietic'],\n",
       "             'abeiint': ['abietin'],\n",
       "             'aabeeeiint': ['abietineae'],\n",
       "             'abeeiinostu': ['abietineous'],\n",
       "             'abceiiint': ['abietinic'],\n",
       "             'abeeirz': ['abiezer'],\n",
       "             'aabgiil': ['abigail'],\n",
       "             'aabghiiilps': ['abigailship'],\n",
       "             'aabegit': ['abigeat'],\n",
       "             'abegisu': ['abigeus'],\n",
       "             'aabilo': ['abilao'],\n",
       "             'abiilty': ['ability'],\n",
       "             'aabill': ['abilla', 'labial'],\n",
       "             'abilo': ['abilo', 'aboil'],\n",
       "             'aabeeinsttt': ['abintestate'],\n",
       "             'abeegiinoss': ['abiogenesis'],\n",
       "             'abeegiinosst': ['abiogenesist'],\n",
       "             'abceegiinot': ['abiogenetic'],\n",
       "             'aabceegiilnot': ['abiogenetical'],\n",
       "             'aabceegiillnoty': ['abiogenetically'],\n",
       "             'abegiinost': ['abiogenist'],\n",
       "             'abeginoosu': ['abiogenous'],\n",
       "             'abeginoy': ['abiogeny'],\n",
       "             'aabcgiilloo': ['abiological'],\n",
       "             'aabcgiilllooy': ['abiologically'],\n",
       "             'abgilooy': ['abiology'],\n",
       "             'abiioss': ['abiosis'],\n",
       "             'abciiot': ['abiotic'],\n",
       "             'abchiiooprt': ['abiotrophic'],\n",
       "             'abhiooprty': ['abiotrophy'],\n",
       "             'abinop': ['abipon'],\n",
       "             'abir': ['abir', 'bari', 'rabi'],\n",
       "             'aabiinrrtt': ['abirritant'],\n",
       "             'aabeiirrtt': ['abirritate'],\n",
       "             'aabiiinorrtt': ['abirritation'],\n",
       "             'aabeiiirrttv': ['abirritative'],\n",
       "             'abinost': ['abiston', 'bastion'],\n",
       "             'abbiiit': ['abitibi'],\n",
       "             'abeirtu': ['abiuret', 'aubrite', 'biurate', 'rubiate'],\n",
       "             'abcejt': ['abject'],\n",
       "             'abcdeeejnsst': ['abjectedness'],\n",
       "             'abceijnot': ['abjection'],\n",
       "             'abceeijtv': ['abjective'],\n",
       "             'abcejlty': ['abjectly'],\n",
       "             'abceejnsst': ['abjectness'],\n",
       "             'abijnot': ['abjoint'],\n",
       "             'abdegju': ['abjudge'],\n",
       "             'aabcdeijtu': ['abjudicate'],\n",
       "             'aabcdiijnotu': ['abjudication'],\n",
       "             'abcijnnotu': ['abjunction'],\n",
       "             'abceijntuv': ['abjunctive'],\n",
       "             'aabijnortu': ['abjuration'],\n",
       "             'aabjorrtuy': ['abjuratory'],\n",
       "             'abejru': ['abjure'],\n",
       "             'abeejmnrtu': ['abjurement'],\n",
       "             'abejrru': ['abjurer'],\n",
       "             'aabkr': ['abkar', 'arkab'],\n",
       "             'aabikr': ['abkari'],\n",
       "             'aabhks': ['abkhas', 'kasbah'],\n",
       "             'aaabhikns': ['abkhasian'],\n",
       "             'aabchl': ['ablach'],\n",
       "             'aaabceltt': ['ablactate', 'cabaletta'],\n",
       "             'aaabcilnott': ['ablactation'],\n",
       "             'aabelr': ['ablare', 'arable', 'arbela'],\n",
       "             'aabceilmst': ['ablastemic', 'masticable'],\n",
       "             'aablosstu': ['ablastous'],\n",
       "             'aabelt': ['ablate'],\n",
       "             'aabilnot': ['ablation', 'obtainal'],\n",
       "             'aabiilosttu': ['ablatitious'],\n",
       "             'aaabilltv': ['ablatival'],\n",
       "             'aabeiltv': ['ablative'],\n",
       "             'aablort': ['ablator'],\n",
       "             'aabltu': ['ablaut', 'tabula'],\n",
       "             'aabelz': ['ablaze'],\n",
       "             'abeeelz': ['ableeze'],\n",
       "             'aabeeglt': ['ablegate'],\n",
       "             'abeelnss': ['ableness', 'blaeness', 'sensable'],\n",
       "             'aaabehilpr': ['ablepharia'],\n",
       "             'aabehlnopr': ['ablepharon'],\n",
       "             'aabehloprsu': ['ablepharous'],\n",
       "             'aabehlprsu': ['ablepharus'],\n",
       "             'aabeilps': ['ablepsia', 'epibasal'],\n",
       "             'aabceillpt': ['ableptical'],\n",
       "             'aabceilllpty': ['ableptically'],\n",
       "             'abelr': ['abler', 'baler', 'belar', 'blare', 'blear'],\n",
       "             'abelst': ['ablest', 'stable', 'tables'],\n",
       "             'aabceehklstw': ['ablewhackets'],\n",
       "             'abilns': ['ablins'],\n",
       "             'ablmoo': ['abloom', 'mabolo'],\n",
       "             'ablow': ['ablow', 'balow', 'bowla'],\n",
       "             'abdelu': ['ablude', 'belaud'],\n",
       "             'abelntu': ['abluent', 'tunable'],\n",
       "             'abhlsu': ['ablush'],\n",
       "             'abilnotu': ['ablution', 'abutilon'],\n",
       "             'aabilnortuy': ['ablutionary'],\n",
       "             'abilnouv': ['abluvion'],\n",
       "             'ably': ['ably', 'blay', 'yalb'],\n",
       "             'abhmo': ['abmho', 'abohm'],\n",
       "             'aabikn': ['abnaki'],\n",
       "             'aabeegnt': ['abnegate'],\n",
       "             'aabeginnot': ['abnegation'],\n",
       "             'aabeegintv': ['abnegative'],\n",
       "             'aabegnort': ['abnegator'],\n",
       "             'abenr': ['abner', 'arneb', 'reban'],\n",
       "             'aabelnrv': ['abnerval'],\n",
       "             'abent': ['abnet', 'beant'],\n",
       "             'aabelnru': ['abneural'],\n",
       "             'aablmnor': ['abnormal'],\n",
       "             'aabilmmnors': ['abnormalism'],\n",
       "             'aabilmnorst': ['abnormalist'],\n",
       "             'aabilmnorty': ['abnormality'],\n",
       "             'aabeilmnorz': ['abnormalize'],\n",
       "             'aabllmnory': ['abnormally'],\n",
       "             'aabelmnnorss': ['abnormalness'],\n",
       "             'abimnorty': ['abnormity'],\n",
       "             'abmnoorsu': ['abnormous'],\n",
       "             'aabbeelmnru': ['abnumerable'],\n",
       "             'abo': ['abo', 'boa'],\n",
       "             'aabdor': ['aboard', 'aborad', 'abroad'],\n",
       "             'aabbor': ['abobra'],\n",
       "             'abdeo': ['abode', 'adobe'],\n",
       "             'abdeemnot': ['abodement'],\n",
       "             'abdoy': ['abody'],\n",
       "             'abhilos': ['abolish'],\n",
       "             'abehilors': ['abolisher', 'reabolish'],\n",
       "             'abehilmnost': ['abolishment'],\n",
       "             'abiilnoot': ['abolition'],\n",
       "             'aabiilnoorty': ['abolitionary'],\n",
       "             'abiiilmnoost': ['abolitionism'],\n",
       "             'abiiilnoostt': ['abolitionist'],\n",
       "             'abeiiilnootz': ['abolitionize'],\n",
       "             'aabllo': ['abolla'],\n",
       "             'aabmo': ['aboma'],\n",
       "             'aabmmosu': ['abomasum'],\n",
       "             'aabmossu': ['abomasus'],\n",
       "             'aabbeilmno': ['abominable'],\n",
       "             'aabbeeilmnnoss': ['abominableness'],\n",
       "             'aabbilmnoy': ['abominably'],\n",
       "             'aabeimnot': ['abominate'],\n",
       "             'aabiimnnoot': ['abomination'],\n",
       "             'aabimnoort': ['abominator'],\n",
       "             'abeimno': ['abomine'],\n",
       "             'abgnoo': ['abongo', 'gaboon'],\n",
       "             'abnoo': ['aboon'],\n",
       "             'aablor': ['aboral', 'arbalo'],\n",
       "             'aabllory': ['aborally'],\n",
       "             'abdor': ['abord', 'bardo', 'board', 'broad', 'dobra', 'dorab'],\n",
       "             'aabgiilnor': ['aboriginal'],\n",
       "             'aabgiiilnorty': ['aboriginality'],\n",
       "             'aabgiillnory': ['aboriginally'],\n",
       "             'aabgiinorry': ['aboriginary'],\n",
       "             'abegiinor': ['aborigine'],\n",
       "             'abort': ['abort', 'tabor'],\n",
       "             'abdeort': ['aborted'],\n",
       "             'abcdeiiort': ['aborticide', 'bacterioid'],\n",
       "             'abeinortt': ['abortient', 'torbanite'],\n",
       "             'aabcefiinortt': ['abortifacient'],\n",
       "             'abinort': ['abortin', 'taborin'],\n",
       "             'abinoort': ['abortion', 'robotian'],\n",
       "             'aabilnoort': ['abortional'],\n",
       "             'abiinoorstt': ['abortionist'],\n",
       "             'abeiortv': ['abortive', 'bravoite'],\n",
       "             'abeilortvy': ['abortively'],\n",
       "             'abeeinorsstv': ['abortiveness'],\n",
       "             'aborstu': ['abortus'],\n",
       "             'abceehmnotu': ['abouchement'],\n",
       "             'abdnou': ['abound'],\n",
       "             'abdenoru': ['abounder'],\n",
       "             'abdginnou': ['abounding'],\n",
       "             'abdgilnnouy': ['aboundingly'],\n",
       "             'abotu': ['about'],\n",
       "             'abostu': ['abouts', 'basuto'],\n",
       "             'abeov': ['above'],\n",
       "             'aabbdeoorv': ['aboveboard'],\n",
       "             'abcdeekov': ['abovedeck'],\n",
       "             'abdegnooruv': ['aboveground'],\n",
       "             'abefoooprv': ['aboveproof'],\n",
       "             'aabeiorsstv': ['abovestairs'],\n",
       "             'abox': ['abox'],\n",
       "             'aaaaabbcdrr': ['abracadabra'],\n",
       "             'aaabchir': ['abrachia'],\n",
       "             'aaabdnrt': ['abradant'],\n",
       "             'aabder': ['abrade'],\n",
       "             'aabderr': ['abrader'],\n",
       "             'aaabhmr': ['abraham'],\n",
       "             'aaabchimr': ['abrahamic'],\n",
       "             'aaaabdehimr': ['abrahamidae'],\n",
       "             'aaabehimrt': ['abrahamite'],\n",
       "             'aaabchiimrt': ['abrahamitic'],\n",
       "             'aabdir': ['abraid'],\n",
       "             'aabmr': ['abram', 'ambar'],\n",
       "             'aabimrs': ['abramis', 'arabism'],\n",
       "             'aaabchilnr': ['abranchial'],\n",
       "             'aaabchiilmnrs': ['abranchialism'],\n",
       "             'aaabchinnr': ['abranchian'],\n",
       "             'aaaabchinrt': ['abranchiata'],\n",
       "             'aaabcehinrt': ['abranchiate'],\n",
       "             'aabchinorsu': ['abranchious'],\n",
       "             'aaabrsx': ['abrasax', 'abraxas'],\n",
       "             'aabhrs': ['abrash'],\n",
       "             'aabeeimorrst': ['abrasiometer'],\n",
       "             'aabinors': ['abrasion', 'sorabian'],\n",
       "             'aabeirsv': ['abrasive'],\n",
       "             'aablorst': ['abrastol', 'albatros'],\n",
       "             'aabmru': ['abraum'],\n",
       "             'aabcert': ['abreact', 'bractea', 'cabaret'],\n",
       "             'aabceinort': ['abreaction'],\n",
       "             'aaberst': ['abreast'],\n",
       "             'abceennoru': ['abrenounce'],\n",
       "             'abert': ['abret', 'bater', 'berat'],\n",
       "             'abcior': ['abrico'],\n",
       "             'abdegir': ['abridge', 'brigade'],\n",
       "             'aabbdeegilr': ['abridgeable'],\n",
       "             'abddegir': ['abridged'],\n",
       "             'abddegilry': ['abridgedly'],\n",
       "             'abdegirr': ['abridger'],\n",
       "             'abdegimnrt': ['abridgment'],\n",
       "             'abimr': ['abrim', 'birma'],\n",
       "             'abinr': ['abrin', 'bairn', 'brain', 'brian', 'rabin'],\n",
       "             'abeilrst': ['abristle', 'libertas'],\n",
       "             'aabchor': ['abroach'],\n",
       "             'aabcmoor': ['abrocoma'],\n",
       "             'abcemoor': ['abrocome'],\n",
       "             'aabbeglor': ['abrogable'],\n",
       "             'aabegort': ['abrogate'],\n",
       "             'aabginoort': ['abrogation'],\n",
       "             'aabegiortv': ['abrogative'],\n",
       "             'aabgoorrt': ['abrogator'],\n",
       "             'aabmor': ['abroma'],\n",
       "             'aabinor': ['abronia'],\n",
       "             'abkoor': ['abrook'],\n",
       "             'aabmnortu': ['abrotanum'],\n",
       "             'abeinort': ['abrotine', 'baritone', 'obtainer', 'reobtain'],\n",
       "             'abprtu': ['abrupt'],\n",
       "             'abdelprtuy': ['abruptedly'],\n",
       "             'abinoprtu': ['abruption'],\n",
       "             'ablprtuy': ['abruptly'],\n",
       "             'abenprsstu': ['abruptness'],\n",
       "             'abrsu': ['abrus', 'bursa', 'subra'],\n",
       "             'aablmos': ['absalom', 'balsamo'],\n",
       "             'aabeemprs': ['absampere'],\n",
       "             'aaabkors': ['absaroka'],\n",
       "             'aabeikorst': ['absarokite'],\n",
       "             'abcesss': ['abscess'],\n",
       "             'abcdeesss': ['abscessed'],\n",
       "             'abceinosss': ['abscession'],\n",
       "             'abceoorssst': ['abscessroot'],\n",
       "             'abcdins': ['abscind'],\n",
       "             'abceiss': ['abscise', 'scabies'],\n",
       "             'abciinoss': ['abscision'],\n",
       "             'abcisss': ['absciss'],\n",
       "             'aabcisss': ['abscissa'],\n",
       "             'aabceisss': ['abscissae'],\n",
       "             'abceisss': ['abscisse'],\n",
       "             'abciinosss': ['abscission'],\n",
       "             'abccenos': ['absconce'],\n",
       "             'abcdnos': ['abscond'],\n",
       "             'abcddenos': ['absconded'],\n",
       "             'abcddelnosy': ['abscondedly'],\n",
       "             'abccdeennos': ['abscondence'],\n",
       "             'abcdenors': ['absconder'],\n",
       "             'aabcnoss': ['absconsa'],\n",
       "             'abbclmoosu': ['abscoulomb'],\n",
       "             'abceens': ['absence'],\n",
       "             'abenst': ['absent', 'basten'],\n",
       "             'aabeinnostt': ['absentation'],\n",
       "             'abeeenst': ['absentee'],\n",
       "             'abeeeimnsst': ['absenteeism'],\n",
       "             'abeeehinpsst': ['absenteeship'],\n",
       "             'abeenrst': ['absenter', 'reabsent'],\n",
       "             'abelnsty': ['absently'],\n",
       "             'abeemnnstt': ['absentment'],\n",
       "             'abddeeilmnnsty': ['absentmindedly'],\n",
       "             'abeennssst': ['absentness'],\n",
       "             'aaabdfrs': ['absfarad'],\n",
       "             'abehnrsy': ['abshenry'],\n",
       "             'abis': ['absi', 'bais', 'bias', 'isba'],\n",
       "             'abehinst': ['absinthe'],\n",
       "             'aabhiilnst': ['absinthial'],\n",
       "             'aabhiinnst': ['absinthian'],\n",
       "             'aabehiinstt': ['absinthiate'],\n",
       "             'abchiinst': ['absinthic'],\n",
       "             'abhiinnst': ['absinthin'],\n",
       "             'abehiinnst': ['absinthine'],\n",
       "             'abhiimnsst': ['absinthism'],\n",
       "             'abchiiimnsst': ['absinthismic'],\n",
       "             'abhiimnstu': ['absinthium'],\n",
       "             'abhilnost': ['absinthol'],\n",
       "             'abist': ['absit', 'batis'],\n",
       "             'abhmos': ['absmho', 'absohm'],\n",
       "             'abelostu': ['absolute'],\n",
       "             'abellostuy': ['absolutely'],\n",
       "             'abeelnossstu': ['absoluteness'],\n",
       "             'abilnoostu': ['absolution'],\n",
       "             'abilmosstu': ['absolutism'],\n",
       "             'abilossttu': ['absolutist'],\n",
       "             'abciilossttu': ['absolutistic'],\n",
       "             'aabciilllossttuy': ['absolutistically'],\n",
       "             'abeilostuv': ['absolutive'],\n",
       "             'aabiilnoosttuz': ['absolutization'],\n",
       "             'abeilostuz': ['absolutize'],\n",
       "             'abloorstuy': ['absolutory'],\n",
       "             'aabbellosv': ['absolvable'],\n",
       "             'aabloorstvy': ['absolvatory'],\n",
       "             'abelosv': ['absolve'],\n",
       "             'abelnostv': ['absolvent'],\n",
       "             'abelorsv': ['absolver'],\n",
       "             'abiloorstv': ['absolvitor'],\n",
       "             'abiloorstvy': ['absolvitory'],\n",
       "             'aabnnost': ['absonant'],\n",
       "             'abnoossu': ['absonous'],\n",
       "             'abbors': ['absorb'],\n",
       "             'aabbbiilorsty': ['absorbability'],\n",
       "             'aabbbelors': ['absorbable'],\n",
       "             'abbdeors': ['absorbed'],\n",
       "             'abbdelorsy': ['absorbedly'],\n",
       "             'abbdeenorsss': ['absorbedness'],\n",
       "             'aabbceefinorst': ['absorbefacient'],\n",
       "             'abbcenorsy': ['absorbency'],\n",
       "             'abbenorst': ['absorbent'],\n",
       "             'abbeorrs': ['absorber', 'reabsorb'],\n",
       "             'abbginors': ['absorbing'],\n",
       "             'abbgilnorsy': ['absorbingly'],\n",
       "             'abbiinoorst': ['absorbition'],\n",
       "             'aboprst': ['absorpt', 'barpost'],\n",
       "             'aabcenoprst': ['absorptance'],\n",
       "             'abeeimooprrstt': ['absorptiometer'],\n",
       "             'abceiimooprrstt': ['absorptiometric'],\n",
       "             'abinooprst': ['absorption'],\n",
       "             'abeioprstv': ['absorptive'],\n",
       "             'abeiloprstvy': ['absorptively'],\n",
       "             'abeeinoprssstv': ['absorptiveness'],\n",
       "             'abiioprsttvy': ['absorptivity'],\n",
       "             'aaabelqsttuu': ['absquatulate'],\n",
       "             'aabinst': ['abstain'],\n",
       "             'aabeinrst': ['abstainer'],\n",
       "             'aabeimnnstt': ['abstainment'],\n",
       "             'abeimosstu': ['abstemious'],\n",
       "             'abeilmosstuy': ['abstemiously'],\n",
       "             'abeeimnosssstu': ['abstemiousness'],\n",
       "             'abeinnostt': ['abstention'],\n",
       "             'abeiinnossttt': ['abstentionist'],\n",
       "             'abeinossttu': ['abstentious'],\n",
       "             'abeegrst': ['absterge'],\n",
       "             'abeegnrstt': ['abstergent'],\n",
       "             'abeinorsst': ['abstersion'],\n",
       "             'abeeirsstv': ['abstersive'],\n",
       "             'abeeeinrsssstv': ['abstersiveness'],\n",
       "             'abceeinnst': ['abstinence'],\n",
       "             'abceinnsty': ['abstinency'],\n",
       "             'abeinnstt': ['abstinent'],\n",
       "             'aabeiilnnstt': ['abstinential'],\n",
       "             'abeilnnstty': ['abstinently'],\n",
       "             'aabcrstt': ['abstract'],\n",
       "             'aabcderstt': ['abstracted'],\n",
       "             'aabcdelrstty': ['abstractedly'],\n",
       "             'aabcdeenrssstt': ['abstractedness'],\n",
       "             'aabcerrstt': ['abstracter'],\n",
       "             'aabcinorstt': ['abstraction'],\n",
       "             'aaabcilnorstt': ['abstractional'],\n",
       "             'aabciimnorsstt': ['abstractionism'],\n",
       "             'aabciinorssttt': ['abstractionist'],\n",
       "             'aabciiorsstttu': ['abstractitious'],\n",
       "             'aabceirsttv': ['abstractive'],\n",
       "             'aabceilrsttvy': ['abstractively'],\n",
       "             'aabceeinrsssttv': ['abstractiveness'],\n",
       "             'aabclrstty': ['abstractly'],\n",
       "             'aabcenrssstt': ['abstractness'],\n",
       "             'aabcorrstt': ['abstractor'],\n",
       "             'aabehnrstt': ['abstrahent'],\n",
       "             'abcdeirstt': ['abstricted'],\n",
       "             'abciinorstt': ['abstriction'],\n",
       "             'abersstu': ['abstruse'],\n",
       "             'abelrsstuy': ['abstrusely'],\n",
       "             'abeenrsssstu': ['abstruseness'],\n",
       "             'abinorsstu': ['abstrusion'],\n",
       "             'abirssttuy': ['abstrusity'],\n",
       "             'abemsu': ['absume'],\n",
       "             'abimnopstu': ['absumption'],\n",
       "             'abdrsu': ['absurd'],\n",
       "             'abdirstuy': ['absurdity'],\n",
       "             'abdlrsuy': ['absurdly'],\n",
       "             'abdenrsssu': ['absurdness'],\n",
       "             'ablostv': ['absvolt'],\n",
       "             'abrsstuy': ['absyrtus'],\n",
       "             'aabeilmnrt': ['abterminal'],\n",
       "             'aabhint': ['abthain', 'habitan'],\n",
       "             'aabehiinrt': ['abthainrie'],\n",
       "             'aabhinrty': ['abthainry'],\n",
       "             'aaabeghnt': ['abthanage'],\n",
       "             'abu': ['abu'],\n",
       "             'abccou': ['abucco'],\n",
       "             'aabilu': ['abulia'],\n",
       "             'abcilu': ['abulic', 'baculi'],\n",
       "             'aaabilmnou': ['abulomania'],\n",
       "             'aabnu': ['abuna'],\n",
       "             'aabcdennu': ['abundance'],\n",
       "             'aabcdnnuy': ['abundancy'],\n",
       "             'aabdnntu': ['abundant'],\n",
       "             'aaabdinntu': ['abundantia'],\n",
       "             'aabdlnntuy': ['abundantly'],\n",
       "             'aabru': ['abura'],\n",
       "             'aabboruuz': ['aburabozu'],\n",
       "             'aabbnru': ['aburban'],\n",
       "             'abrstu': ['aburst'],\n",
       "             'abnortu': ['aburton'],\n",
       "             'aabbelsu': ['abusable'],\n",
       "             'abesu': ['abuse'],\n",
       "             'abdelsuy': ['abusedly'],\n",
       "             'abeesu': ['abusee'],\n",
       "             'abeflsuu': ['abuseful'],\n",
       "             'abefllsuuy': ['abusefully'],\n",
       "             'abeeflnsssuu': ['abusefulness'],\n",
       "             'abersu': ['abuser'],\n",
       "             'abinosu': ['abusion'],\n",
       "             'abiossuu': ['abusious'],\n",
       "             'abeisuv': ['abusive'],\n",
       "             'abeilsuvy': ['abusively'],\n",
       "             'abeeinsssuv': ['abusiveness'],\n",
       "             'abtu': ['abut', 'tabu', 'tuba'],\n",
       "             'aabtu': ['abuta', 'bauta'],\n",
       "             'abemnttu': ['abutment'],\n",
       "             'aablttu': ['abuttal'],\n",
       "             'aberttu': ['abutter'],\n",
       "             'abginttu': ['abutting'],\n",
       "             'abuzz': ['abuzz'],\n",
       "             'ablotv': ['abvolt'],\n",
       "             'aabbw': ['abwab'],\n",
       "             'aby': ['aby', 'bay'],\n",
       "             'abmsy': ['abysm'],\n",
       "             'aablmsy': ['abysmal', 'balsamy'],\n",
       "             'aabllmsyy': ['abysmally'],\n",
       "             'abssy': ['abyss'],\n",
       "             'aablssy': ['abyssal'],\n",
       "             'aabiinnssy': ['abyssinian'],\n",
       "             'abbcehinnoossty': ['abyssobenthonic'],\n",
       "             'abhilossty': ['abyssolith'],\n",
       "             'aabcegilopssy': ['abyssopelagic'],\n",
       "             'aaacccehint': ['acacatechin'],\n",
       "             'aaacccehlot': ['acacatechol'],\n",
       "             'aacceint': ['acacetin'],\n",
       "             'aaacci': ['acacia'],\n",
       "             'aaaccin': ['acacian'],\n",
       "             'aacciin': ['acaciin'],\n",
       "             'aaccin': ['acacin'],\n",
       "             'aacdeem': ['academe'],\n",
       "             'aaacdeilm': ['academial'],\n",
       "             'aaacdeimn': ['academian'],\n",
       "             'aaccdeim': ['academic'],\n",
       "             'aaaccdeilm': ['academical'],\n",
       "             'aaaccdeillmy': ['academically'],\n",
       "             'aaaccdeilms': ['academicals'],\n",
       "             'aaaccdeiimn': ['academician'],\n",
       "             'aaccdeiimms': ['academicism'],\n",
       "             'aacdeimms': ['academism'],\n",
       "             'aacdeimst': ['academist'],\n",
       "             'aacdeeimt': ['academite', 'acetamide'],\n",
       "             'aaacdeiimnotz': ['academization'],\n",
       "             'aacdeeimz': ['academize'],\n",
       "             'aacdemsu': ['academus'],\n",
       "             'aacdemy': ['academy'],\n",
       "             'aaacdi': ['acadia'],\n",
       "             'aaacdeiilt': ['acadialite'],\n",
       "             'aaacdin': ['acadian'],\n",
       "             'aacdei': ['acadie', 'acedia', 'adicea'],\n",
       "             'aaacen': ['acaena'],\n",
       "             'aacjou': ['acajou'],\n",
       "             'aacehlp': ['acaleph', 'acephal'],\n",
       "             'aaacehlp': ['acalepha', 'acephala'],\n",
       "             'aaaceehlp': ['acalephae', 'apalachee'],\n",
       "             'aaacehlnp': ['acalephan', 'acephalan'],\n",
       "             'aacdehilop': ['acalephoid'],\n",
       "             'aaacclly': ['acalycal'],\n",
       "             'aacceilny': ['acalycine'],\n",
       "             'aaccilnosuy': ['acalycinous'],\n",
       "             'aaaccelltuy': ['acalyculate'],\n",
       "             'aaachlpy': ['acalypha'],\n",
       "             'aaaceelprty': ['acalypterae'],\n",
       "             'aaaaclprtty': ['acalyptrata'],\n",
       "             'aaaacelprtty': ['acalyptratae'],\n",
       "             'aaacelprtty': ['acalyptrate', 'calyptratae'],\n",
       "             'aaacmr': ['acamar', 'camara', 'maraca'],\n",
       "             'aaacimps': ['acampsia'],\n",
       "             'aaacn': ['acana'],\n",
       "             'aaaccenosu': ['acanaceous'],\n",
       "             'aaaccilnno': ['acanonical'],\n",
       "             'aachnt': ['acanth', 'anchat', 'tanach'],\n",
       "             'aaachnt': ['acantha'],\n",
       "             'aaaacceehnt': ['acanthaceae'],\n",
       "             'aaaccehnostu': ['acanthaceous'],\n",
       "             'aaacdhnt': ['acanthad'],\n",
       "             'aaaachinrt': ['acantharia'],\n",
       "             'aaachint': ['acanthia', 'achatina'],\n",
       "             'aaachilnt': ['acanthial', 'calathian'],\n",
       "             'aachinnt': ['acanthin', 'chinanta'],\n",
       "             'aacehinnt': ['acanthine'],\n",
       "             'aachinnot': ['acanthion'],\n",
       "             'aacehintt': ['acanthite'],\n",
       "             'aaacchnooprstu': ['acanthocarpous'],\n",
       "             'aaaaccehhlnopt': ['acanthocephala'],\n",
       "             'aaaaccehhlnnopt': ['acanthocephalan'],\n",
       "             'aaaccehhilnopt': ['acanthocephali'],\n",
       "             'aaaccehhlnoopstu': ['acanthocephalous'],\n",
       "             'aacceehnorstu': ['acanthocereus'],\n",
       "             'aaaccdhlnoostu': ['acanthocladous'],\n",
       "             'aaacdehnot': ['acanthodea'],\n",
       "             'aaacdehnnot': ['acanthodean'],\n",
       "             'aacdehinot': ['acanthodei'],\n",
       "             'aacdehnost': ['acanthodes'],\n",
       "             'aaacdhinnot': ['acanthodian'],\n",
       "             'aaacddehinot': ['acanthodidae'],\n",
       "             'aacdhiinot': ['acanthodii'],\n",
       "             'aacdhiinnot': ['acanthodini'],\n",
       "             'aacdhinot': ['acanthoid'],\n",
       "             'aachilmnnoot': ['acantholimon'],\n",
       "             'aaaccghillnoot': ['acanthological'],\n",
       "             'aacghlnooty': ['acanthology'],\n",
       "             'aachilnossty': ['acantholysis'],\n",
       "             'aaachmnot': ['acanthoma'],\n",
       "             'aaacdeehimnort': ['acanthomeridae'],\n",
       "             'aachnnot': ['acanthon'],\n",
       "             'aaaachnnoptx': ['acanthopanax'],\n",
       "             'aachhinopst': ['acanthophis'],\n",
       "             'aachhnoooprstu': ['acanthophorous'],\n",
       "             'aacdhnoopt': ['acanthopod'],\n",
       "             'aacdhnooopstu': ['acanthopodous'],\n",
       "             'aaachmnooopsttu': ['acanthopomatous'],\n",
       "             'aacehnooprt': ['acanthopore'],\n",
       "             'aaacehnnoprtt': ['acanthopteran'],\n",
       "             'aacehinoprtt': ['acanthopteri'],\n",
       "             'aacehnooprsttu': ['acanthopterous'],\n",
       "             'aaaceghinnoprtty': ['acanthopterygian'],\n",
       "             'aaceghiinoprtty': ['acanthopterygii'],\n",
       "             'aachinosst': ['acanthosis'],\n",
       "             'aachnostu': ['acanthous'],\n",
       "             'aaacdehinrtu': ['acanthuridae'],\n",
       "             'aachnrstuu': ['acanthurus'],\n",
       "             'aachnstu': ['acanthus'],\n",
       "             'aaacinp': ['acapnia'],\n",
       "             'aaacilnp': ['acapnial'],\n",
       "             'aaaclprsu': ['acapsular'],\n",
       "             'aacpu': ['acapu'],\n",
       "             'aacclopu': ['acapulco'],\n",
       "             'aaacr': ['acara', 'araca'],\n",
       "             'aaaciprs': ['acarapis'],\n",
       "             'aaacdir': ['acardia', 'acarida', 'arcadia'],\n",
       "             'aaaccdir': ['acardiac'],\n",
       "             'aacir': ['acari'],\n",
       "             'aaacinr': ['acarian', 'acarina', 'acrania'],\n",
       "             'aaaciirss': ['acariasis'],\n",
       "             'aaaccdiilr': ['acaricidal'],\n",
       "             'aaccdeiir': ['acaricide'],\n",
       "             'aacdir': ['acarid', 'cardia', 'carida'],\n",
       "             'aaacdeir': ['acaridea'],\n",
       "             'aaacdeinr': ['acaridean'],\n",
       "             'aaacdiimmortu': ['acaridomatium'],\n",
       "             'aacfimorr': ['acariform'],\n",
       "             'aaceinr': ['acarine', 'acraein', 'arecain'],\n",
       "             'aaciinorss': ['acarinosis'],\n",
       "             'aacccdeiimoru': ['acarocecidium'],\n",
       "             'aaacdeiimorrstt': ['acarodermatitis'],\n",
       "             'aacdior': ['acaroid'],\n",
       "             'aaclor': ['acarol'],\n",
       "             'aacgiloorst': ['acarologist'],\n",
       "             'aacgloory': ['acarology'],\n",
       "             'aachilooprsu': ['acarophilous'],\n",
       "             'aaabchioopr': ['acarophobia'],\n",
       "             'aaccioortx': ['acarotoxic'],\n",
       "             'aaceloprsu': ['acarpelous'],\n",
       "             'aacoprsu': ['acarpous'],\n",
       "             'aacrsu': ['acarus'],\n",
       "             'aacsstu': ['acastus', 'astacus'],\n",
       "             'aaaccceiltt': ['acatalectic'],\n",
       "             'aaaaceilpst': ['acatalepsia'],\n",
       "             'aaacelpsty': ['acatalepsy'],\n",
       "             'aaacceilptt': ['acataleptic'],\n",
       "             'aaaacccilltt': ['acatallactic'],\n",
       "             'aaaaacehimstt': ['acatamathesia'],\n",
       "             'aaaaachipst': ['acataphasia'],\n",
       "             'aaaciopsst': ['acataposis'],\n",
       "             'aaaaacisstt': ['acatastasia'],\n",
       "             'aaaaccisttt': ['acatastatic'],\n",
       "             'aacet': ['acate'],\n",
       "             'aaaccegilort': ['acategorical'],\n",
       "             'aacerty': ['acatery'],\n",
       "             'aaaachirst': ['acatharsia'],\n",
       "             'aaachrsty': ['acatharsy'],\n",
       "             'aacchilot': ['acatholic', 'chaotical'],\n",
       "             'aaacdlu': ['acaudal'],\n",
       "             'aaacdetu': ['acaudate', 'ecaudata'],\n",
       "             'aacceelnstu': ['acaulescent'],\n",
       "             'aaceilnu': ['acauline'],\n",
       "             'aacelosu': ['acaulose'],\n",
       "             'aaclosuu': ['acaulous'],\n",
       "             'aacc': ['acca', 'caca'],\n",
       "             'accdee': ['accede'],\n",
       "             'acccdeeen': ['accedence'],\n",
       "             'accdeer': ['acceder'],\n",
       "             'aabcceeellr': ['accelerable'],\n",
       "             'aaccdeelnor': ['accelerando'],\n",
       "             'aacceelnrt': ['accelerant'],\n",
       "             'aacceeelrt': ['accelerate'],\n",
       "             'aaccdeeelrt': ['accelerated'],\n",
       "             'aaccdeeellrty': ['acceleratedly'],\n",
       "             'aacceeilnort': ['acceleration'],\n",
       "             'aacceeeilrtv': ['accelerative'],\n",
       "             'aacceelorrt': ['accelerator', 'retrocaecal'],\n",
       "             'aacceelorrty': ['acceleratory'],\n",
       "             'aacceeghloprr': ['accelerograph'],\n",
       "             'acceeeelmorrt': ['accelerometer'],\n",
       "             'accden': ['accend'],\n",
       "             'abccdeiiilnty': ['accendibility'],\n",
       "             'abccdeeiln': ['accendible'],\n",
       "             'acceinnos': ['accension'],\n",
       "             'accenors': ['accensor'],\n",
       "             'accent': ['accent'],\n",
       "             'acceelnsst': ['accentless'],\n",
       "             'accenort': ['accentor'],\n",
       "             'aabcceelntu': ['accentuable'],\n",
       "             'aaccelntu': ['accentual'],\n",
       "             'aacceilnttuy': ['accentuality'],\n",
       "             'aaccellntuy': ['accentually'],\n",
       "             'aacceenttu': ['accentuate'],\n",
       "             'aacceinnottu': ['accentuation'],\n",
       "             'aaccenorttu': ['accentuator'],\n",
       "             'accenstu': ['accentus'],\n",
       "             'accept': ['accept'],\n",
       "             'aabcceiilptty': ['acceptability'],\n",
       "             'aabcceelpt': ['acceptable'],\n",
       "             'aabcceeelnpsst': ['acceptableness'],\n",
       "             'aabccelpty': ['acceptably'],\n",
       "             'aaccceenpt': ['acceptance'],\n",
       "             'aacccenpty': ['acceptancy'],\n",
       "             'aaccenptt': ['acceptant'],\n",
       "             'aacceinoptt': ['acceptation'],\n",
       "             'accdeept': ['accepted'],\n",
       "             'accdeelpty': ['acceptedly'],\n",
       "             'acceeprt': ['accepter'],\n",
       "             'aacceeilptt': ['acceptilate'],\n",
       "             'aacceiilnoptt': ['acceptilation'],\n",
       "             'acceinopt': ['acception', 'peccation'],\n",
       "             'acceeiptv': ['acceptive'],\n",
       "             'acceoprt': ['acceptor'],\n",
       "             'acceeprsst': ['acceptress'],\n",
       "             'acceers': ['accerse'],\n",
       "             'acceiinorst': ['accersition'],\n",
       "             'acceiorrst': ['accersitor'],\n",
       "             'access': ['access'],\n",
       "             'aacceilrssy': ['accessarily'],\n",
       "             'aacceeinrssss': ['accessariness'],\n",
       "             'aaccerssy': ['accessary'],\n",
       "             'aaccehiprsssy': ['accessaryship'],\n",
       "             'abcceiiilssty': ['accessibility'],\n",
       "             'abcceeilss': ['accessible'],\n",
       "             'abcceilssy': ['accessibly'],\n",
       "             'acceinoss': ['accession'],\n",
       "             'aacceilnoss': ['accessional'],\n",
       "             'acceeinorss': ['accessioner', 'reaccession'],\n",
       "             'acceeissv': ['accessive'],\n",
       "             'acceeilssvy': ['accessively'],\n",
       "             'acceelssss': ['accessless'],\n",
       "             'aacceilorss': ['accessorial'],\n",
       "             'acceilorssy': ['accessorily'],\n",
       "             'acceeinorssss': ['accessoriness'],\n",
       "             'acceiorsssu': ['accessorius'],\n",
       "             'acceorssy': ['accessory'],\n",
       "             'acccdeein': ['accidence'],\n",
       "             'acccdeiny': ['accidency'],\n",
       "             'accdeint': ['accident'],\n",
       "             'aaccdeilnt': ['accidental'],\n",
       "             'aaccdeiilmnst': ['accidentalism'],\n",
       "             'aaccdeiilnstt': ['accidentalist'],\n",
       "             'aaccdeiilntty': ['accidentality'],\n",
       "             'aaccdeillnty': ['accidentally'],\n",
       "             'aaccdeeilnnsst': ['accidentalness'],\n",
       "             'accddeeint': ['accidented'],\n",
       "             'aaccdeiilnt': ['accidential'],\n",
       "             'aaccdeiiilntty': ['accidentiality'],\n",
       "             'accdeilnty': ['accidently'],\n",
       "             'aaccdii': ['accidia'],\n",
       "             'accdeii': ['accidie'],\n",
       "             'accegin': ['accinge'],\n",
       "             'acceiinpt': ['accipient'],\n",
       "             'acceiiprt': ['accipiter'],\n",
       "             'aacciilprt': ['accipitral'],\n",
       "             'aacciiprrty': ['accipitrary'],\n",
       "             'acceiiprst': ['accipitres', 'preascitic'],\n",
       "             'acceiiinprt': ['accipitrine'],\n",
       "             'accimssu': ['accismus'],\n",
       "             'acceit': ['accite', 'acetic'],\n",
       "             'aaccilm': ['acclaim'],\n",
       "             'aaabcceillm': ['acclaimable'],\n",
       "             'aacceilmr': ['acclaimer'],\n",
       "             'aaaccilmnot': ['acclamation'],\n",
       "             'aaacclmort': ['acclamator'],\n",
       "             'aaacclmorty': ['acclamatory'],\n",
       "             'aaabcceillmt': ['acclimatable'],\n",
       "             'aaacciilmnott': ['acclimatation'],\n",
       "             'aacceilmt': ['acclimate'],\n",
       "             'aacceeilmmntt': ['acclimatement'],\n",
       "             'aacciilmnot': ['acclimation'],\n",
       "             'aaabcceiillmtz': ['acclimatizable'],\n",
       "             'aaacciiilmnottz': ['acclimatization'],\n",
       "             'aacceiilmtz': ['acclimatize'],\n",
       "             'aacceiilmrtz': ['acclimatizer'],\n",
       "             'aacceilmrtu': ['acclimature'],\n",
       "             'aaccilln': ['acclinal'],\n",
       "             'aacceilnt': ['acclinate', 'analectic'],\n",
       "             'acciilostuv': ['acclivitous'],\n",
       "             'acciiltvy': ['acclivity'],\n",
       "             'accilosuv': ['acclivous'],\n",
       "             'accloy': ['accloy'],\n",
       "             'aaccost': ['accoast'],\n",
       "             'accilo': ['accoil', 'calico'],\n",
       "             'aaccdelo': ['accolade'],\n",
       "             'aaccddelo': ['accoladed'],\n",
       "             'aaccdelot': ['accolated'],\n",
       "             'accelnot': ['accolent'],\n",
       "             'accello': ['accolle'],\n",
       "             'aabcciimnnoot': ['accombination'],\n",
       "             'aabccdelmmoo': ['accommodable'],\n",
       "             'aabccdeelmmnooss': ['accommodableness'],\n",
       "             'aaccdemmoot': ['accommodate'],\n",
       "             'aaccdelmmooty': ['accommodately'],\n",
       "             'aaccdeemmnoosst': ['accommodateness'],\n",
       "             'aaccdgimmnoot': ['accommodating'],\n",
       "             'aaccdgilmmnooty': ['accommodatingly'],\n",
       "             'aaccdimmnooot': ['accommodation'],\n",
       "             'aaaccdilmmnooot': ['accommodational'],\n",
       "             'aaccdeimmootv': ['accommodative'],\n",
       "             'aaccdeeimmnoosstv': ['accommodativeness'],\n",
       "             'aaccdmmooort': ['accommodator'],\n",
       "             'aacceimnopr': ['accompanier'],\n",
       "             'aacceimmnnopt': ['accompaniment'],\n",
       "             'aaacceilmmnnopt': ['accompanimental'],\n",
       "             'aaccimnopst': ['accompanist'],\n",
       "             'aaccmnopy': ['accompany'],\n",
       "             'aaccimnopsty': ['accompanyist'],\n",
       "             'acceeilmoptv': ['accompletive'],\n",
       "             'accceilmop': ['accomplice'],\n",
       "             'acccehiilmopps': ['accompliceship'],\n",
       "             'accciilmopty': ['accomplicity'],\n",
       "             'acchilmops': ['accomplish'],\n",
       "             'aabccehillmops': ['accomplishable'],\n",
       "             'accdehilmops': ['accomplished'],\n",
       "             'accehilmoprs': ['accomplisher', 'reaccomplish'],\n",
       "             'accehilmmnopst': ['accomplishment'],\n",
       "             'acchilmopst': ['accomplisht'],\n",
       "             'accmopt': ['accompt', 'compact'],\n",
       "             'accdor': ['accord'],\n",
       "             'aabccdelor': ['accordable'],\n",
       "             'aacccdenor': ['accordance'],\n",
       "             'aacccdnory': ['accordancy'],\n",
       "             'aaccdnort': ['accordant'],\n",
       "             'aaccdlnorty': ['accordantly'],\n",
       "             'accdeorr': ['accorder', 'reaccord'],\n",
       "             'accdginor': ['according'],\n",
       "             'accdgilnory': ['accordingly'],\n",
       "             'accdinoor': ['accordion'],\n",
       "             'accdiinoorst': ['accordionist'],\n",
       "             'aacceooprrt': ['accorporate'],\n",
       "             'aaccinoooprrt': ['accorporation'],\n",
       "             'accost': ['accost'],\n",
       "             'aabccelost': ['accostable'],\n",
       "             'accdeost': ['accosted'],\n",
       "             'acccehou': ['accouche'],\n",
       "             'accceehmnotu': ['accouchement'],\n",
       "             'acccehoruu': ['accoucheur'],\n",
       "             'accceehosuu': ['accoucheuse'],\n",
       "             'accnotu': ['account'],\n",
       "             ...})"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "words_bysig"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 构建方法 anagram_fast 来快速获得一个单词的变位词\n",
    "\n",
    "其实就是刚才说到的思路：\n",
    "1. 获得该单词的`签名`\n",
    "2. 用`签名`去查上面的`字典`，然后瞬间就可以得到对应的`变位词`列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "def anagram_fast(word):\n",
    "    return words_bysig[signature(word)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['dictionary', 'indicatory']"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "anagram_fast('dictionary')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 构建一个字典 anagrams_all , 包含有所有变位词\n",
    "1. key 是 所有的单词\n",
    "2. value 是 该单词所有的变位词列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "anagrams_all = {word: anagram_fast(word) for word in wordclean if len(anagram_fast(word)) > 1}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "32890"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(anagrams_all)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "900 ms ± 42.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
     ]
    }
   ],
   "source": [
    "%timeit anagrams_all = {word: anagram_fast(word) for word in wordclean if len(anagram_fast(word)) > 1}"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
